package com.common.controller;

import com.common.AliyunOSSUtil;
import com.common.facebody.service.FaceBodyService;
import com.common.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private OssService ossService;

    @Autowired
    private FaceBodyService faceBodyService;

    @PostMapping("/uploadFile")
    public String uploadFile(@RequestParam("file") MultipartFile multipartFile){
        return ossService.uploadMultipartFile(multipartFile);
    }

    @PostMapping("/uploadFileToPath")
    public String uploadFileToPath(@RequestParam("path") String path){
        return ossService.uploadFile(path);
    }
    //人脸识别
    @PostMapping("/searchFace")
    public Object searchFace(@RequestParam("file") MultipartFile multipartFile){
        String faceImgPath = AliyunOSSUtil.uploadMultipartFile(multipartFile,"img");
        return faceBodyService.searchFace("default",faceImgPath,1);
    }


}
